home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl - The Best of BBS
/
Night Owl The Best of BBS (NOP-BBS) (Night Owl Publisher) (1994).iso
/
022a
/
td183buf.lha
/
obsolete
/
td183fix.s
< prev
Wrap
Text File
|
1994-02-25
|
7KB
|
370 lines
*
* D'ya know that TrapDoor 1.83 gurus if during EMSI connections it
* receives a string longer than 512 bytes?
*
* EMSI strings are stored just below the stack. Now, if a string is too
* long it scratches the program stack making each RTS instruction to
* become a ACPU_(#?)Err bomb (return address is stored on the stack).
*
* The patch is VERY SIMPLE: it increases by 64 times the strings buffer
* (old buffer was 512 bytes long, the new buffer is 32752 bytes long).
* The bug is still there, so do not call nodes with more than 32752
* bytes long AKA string ;-)
*
* Have fun,
* /\/ / /-<
*
* You can E-Mail me at:
*
* Fidonet.org: Nicola Soggia (2:331/315.3)
* Amiganet.ftn: Nicola Soggia (39:101/102.3)
* Internet/Arpa: Nicola.Soggia@p3.f315.n331.z2.fidonet.org
*
*
* A0 = scratch D0 = scratch
* A1 = scratch D1 = scratch
* A2 = temp D2 = dos buffer ptr
* A3 = D3 = dos buffer lenght
* A4 = D4 = fhandle
* A5 = buffer ptr D5 = td 1.83 executable size
* A6 = dos base D6 = std in
* A7 = stack ptr D7 = std out
*
INCDIR "include:"
INCLUDE "exec/types.i"
INCLUDE "exec/strings.i"
INCLUDE "exec/exec_lib.i"
INCLUDE "libraries/dos_lib.i"
INCLUDE "libraries/dos.i"
INCLUDE "libraries/dosextens.i"
NULL EQU 0
TDSIZE SET 105664
FILEBND SET 1
BUFSIZE SET 256
STKSIZE SET (32768-BYTESPERLONG) ; TOO BIG (TRY WITH 2KB)
SETMSG MACRO
lea msg\1(pc),a0
moveq #(msg\1e-msg\1),d3
ENDM
**********************************************************************
** MINI-EASYSTART **************************************************
**********************************************************************
suba.l a1,a1 ; = lea #NULL,a1
movea.l 4.w,a6
jsr _LVOFindTask(a6)
movea.l d0,a2
tst.l pr_CLI(a2)
bne.s opendos
lea pr_MsgPort(a2),a0
jsr _LVOWaitPort(a6)
lea pr_MsgPort(a2),a0
jsr _LVOGetMsg(a6)
movea.l d0,a1
jsr _LVOReplyMsg(a6)
moveq #RETURN_OK,d0
rts
**********************************************************************
** REGISTERS SETUP *************************************************
**********************************************************************
opendos lea buffer,a5
move.l #TDSIZE,d5
lea dosname(pc),a1
moveq #33,d0 ; ks 1.2+
jsr _LVOOpenLibrary(a6)
tst.l d0
beq fault
movea.l d0,a6
jsr _LVOInput(a6)
move.l d0,d6
beq clsdos
jsr _LVOOutput(a6)
move.l d0,d7
beq clsdos
**********************************************************************
** GET FILE NAME ***************************************************
**********************************************************************
lea msginf(pc),a0
move.l #(msginfe-msginf),d3
bsr stdout
move.l #BUFSIZE,d3
move.l d6,d1
suba.l d3,sp
move.l sp,d2
jsr _LVORead(a6)
clr.b 0(sp,d0)
cmpi.b #LF,-1(sp,d0)
bne.s opentd
clr.b -1(sp,d0)
**********************************************************************
** READ FILE *******************************************************
**********************************************************************
opentd SETMSG lo3
moveq #NULL,d4
tst.b (sp)
beq.s loading
move.l sp,d1
move.l #MODE_OLDFILE,d2
jsr _LVOOpen(a6)
SETMSG lo1
move.l d0,d4
bne.s loading
SETMSG lo2
loading bsr stdout
move.l d4,d1
beq resetsp
moveq #FILEBND,d3
move.l a5,d2
add.l d5,d3
jsr _LVORead(a6)
SETMSG ld1
cmp.l d0,d5
beq.s repload
SETMSG ld2
cmp.l d0,d5
bgt.s repload
SETMSG ld3
repload movea.l d0,a2
bsr stdout
move.l d4,d1
jsr _LVOClose(a6)
cmp.l a2,d5
bne resetsp
**********************************************************************
** CHECK FILE ******************************************************
**********************************************************************
moveq #(4-1),d0
lea $14ef(a5),a0
getvers asl.l #BITSPERBYTE,d1
move.b (a0)+,d1
dbf d0,getvers
SETMSG ve1
moveq #DOSTRUE,d4
cmpi.l #"1.83",d1
beq.s repver
moveq #DOSFALSE,d4
SETMSG ve2
repver bsr.s stdout
tst.l d4
beq.s resetsp
**********************************************************************
** PATCH FILE ******************************************************
**********************************************************************
lea patch(pc),a0
moveq #((patche-patch)>>2)-1,d0
chgbin movem.w (a0)+,d1-2
move.w d2,0(a5,d1.w)
dbf d0,chgbin
**********************************************************************
** SAVE FILE *******************************************************
**********************************************************************
move.l sp,d1
move.l #MODE_NEWFILE,d2
jsr _LVOOpen(a6)
SETMSG sa1
move.l d0,d4
bne.s saving
SETMSG sa2
saving bsr.s stdout
move.l d4,d1
beq.s resetsp
move.l a5,d2
move.l d5,d3
jsr _LVOWrite(a6)
SETMSG sv1
cmp.l d0,d5
beq.s repsave
SETMSG sv2
repsave movea.l d0,a2
bsr.s stdout
move.l d4,d1
jsr _LVOClose(a6)
cmp.l a2,d5
beq.s resetsp
move.l sp,d1
jsr _LVODeleteFile(a6)
**********************************************************************
** END OF PROGRAM **************************************************
**********************************************************************
resetsp adda.l #BUFSIZE,sp
clsdos movea.l a6,a1
movea.l 4.w,a6
jsr _LVOCloseLibrary(a6)
fault moveq #RETURN_OK,d0
rts
**********************************************************************
** bsr stdout SUBROUTINE *******************************************
**********************************************************************
stdout move.l d7,d1
move.l a0,d2
jmp _LVOWrite(a6)
**********************************************************************
** PATCHES *********************************************************
**********************************************************************
STKSIZE SET STKSIZE & ~%11
IFLE STKSIZE-$20C
FAIL AKAs array is too small
ENDC
IFLT (MININT>>16)-STKSIZE
FAIL AKAs array is too big
ENDC
CNOP 0,BYTESPERLONG
patch DC.W $2972,-STKSIZE
DC.W $2980,-STKSIZE
DC.W $2992,-STKSIZE+BYTESPERLONG
DC.W $29C0,-STKSIZE+BYTESPERLONG
DC.W $29C8,-STKSIZE
patche ; dummy
**********************************************************************
** STRING CONSTANTS ************************************************
**********************************************************************
DC.B "$","VER: TD183_EMSI/AKA_bugfix 33.01 (25.2.94)",EOS
dosname DOSNAME
msginf DC.B "TrapDoor 1.83 EMSI-AKA bugfix",LF
DC.B "by Nicola Soggia (2:331/315.3@Fidonet)",LF
DC.B "",LF
DC.B "WARNING! THE FILE WILL BE OVERWRITTEN, WORK ONLY ON BACKUP COPIES",LF
DC.B "",LF
DC.B "Enter filename: "
msginfe ; dummy
msglo1 DC.B "",LF
DC.B "Reading file... "
msglo1e ; dummy
msglo2 DC.B "",LF
DC.B "Can't read file",LF
msglo2e ; dummy
msglo3 DC.B "",LF
DC.B "Aborted",LF
msglo3e ; dummy
msgld1 DC.B "ok",LF
msgld1e ; dummy
msgld2 DC.B "too short!",LF
msgld2e ; dummy
msgld3 DC.B "too long!",LF
msgld3e ; dummy
msgve1 DC.B "TD recognized and patched",LF
msgve1e ; dummy
msgve2 DC.B "Unknown TD version, sorry",LF
msgve2e ; dummy
msgsa1 DC.B "Writing file... "
msgsa1e ; dummy
msgsa2 DC.B "Can't write file",LF
msgsa2e ; dummy
msgsv1 DC.B "ok",LF
msgsv1e ; dummy
msgsv2 DC.B "error! (deleting file)",LF
msgsv2e ; dummy
**********************************************************************
** TRPADOOR FILE BUFFER ********************************************
**********************************************************************
SECTION BUFFER,BSS
buffer DS.B TDSIZE+FILEBND